home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / pxdds101.zip / DDS.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-05  |  4KB  |  180 lines

  1. {
  2.  
  3. Tests the speed of DOS disk writes and reads.
  4.  
  5. Version 1.01
  6.  
  7. (c) Copyright 1994, Michael Gallias
  8.  
  9. Target: Real
  10.  
  11. }
  12.  
  13.  
  14. Program DDS;
  15.  
  16. {$F-} {$O-} {$A+} {$G-}
  17. {$V-} {$B-} {$X-} {$N+} {$E+}
  18.  
  19. {$M 2048, 65535, 65535}
  20.  
  21. Uses Dos,Calendar,PasStr,CRT;
  22.  
  23. Const
  24.   TempFile = 'TEMP.$$$';
  25.  
  26. Type
  27.   BigBlock      = Array [1..64000] of Byte;
  28.  
  29. Var
  30.   Speeds  :Array[1..1000] of Real;
  31.   Total   :Word;
  32.   P       :^BigBlock;
  33.   F       :File;
  34.  
  35. Function AvSpeed:Real;
  36.  
  37. Var
  38.   Tot:Real;
  39.   X  :Word;
  40.  
  41. Begin
  42.   Tot:=0.0;
  43.   For X:=1 to Total do
  44.     Tot:=Tot + Speeds[X];
  45.   If Total>0.0 Then Tot:=Tot / Total;
  46.   AvSpeed:=Tot;
  47. End;
  48.  
  49. Procedure CreateFile;
  50.  
  51. Var
  52.   X  :Byte;
  53.  
  54. Begin
  55.   Assign(F,'TEMP.$$$');
  56.   Rewrite(F,1);
  57.   For X:=1 to 10 do
  58.     BlockWrite(F,P^,64000);
  59.   If IOResult>0 Then
  60.   Begin
  61.     WriteLn('Not enough disk space.');
  62.     Close(F);
  63.     Assign(F,'TEMP.$$$');
  64.     Erase(F);
  65.     If IOResult>0 Then;
  66.     Halt;
  67.   End
  68.   Else
  69.     Close(F);
  70. End;
  71.  
  72. Procedure WriteSpeed;
  73.  
  74. Var
  75.   X       :Byte;
  76.   Time    :TimeDate;
  77.   Speed   :Real;
  78.   Sec100  :LongInt;
  79.   Sec100a,
  80.   Sec100b :Word;
  81.   Tot1    :LongInt;
  82.  
  83. Begin
  84.   Total:=0;
  85.   Assign(F,TempFile);
  86.   Repeat
  87.     Reset(F,1);
  88.     GetTime(Time.Hour,Time.Min,Time.Sec,Sec100a);
  89.     GetDate(Time.Year,Time.Month,Time.Day,Time.WeekDay);
  90.     Tot1:=TotalSeconds(Time);      {The Current Time, In Seconds}
  91.     For X:=1 to 10 do
  92.       BlockWrite(F,P^,64000);
  93.     GetTime(Time.Hour,Time.Min,Time.Sec,Sec100b);
  94.     GetDate(Time.Year,Time.Month,Time.Day,Time.WeekDay);
  95.     Tot1:=TotalSeconds(Time) - Tot1;     {Current Time Less The Time Above}
  96.     Sec100:=Integer(Sec100b) - Integer(Sec100a);
  97.     Sec100:=Sec100+LongInt(Tot1)*100;    {Time Taken in ms}
  98.     If Sec100=0 Then Sec100:=1;
  99.     Speed:=(640000.0 / (Sec100 / 100.0)) / 1024.0;   {Speed}
  100.     Inc(Total);
  101.     Speeds[Total]:=Speed;
  102.     PushXYPos;
  103.     WriteLn('Last     Write: ',Speed:5:2,' kb per second.  ');
  104.     If Total>1 Then
  105.       WriteLn('Average  Write: ',AvSpeed:5:2,' kb per second.   ',Total:4,' Tests Complete.  ');
  106.     PopXYPos;
  107.   Until KeyPressed Or (Total=1000);
  108.   Close(F);
  109.   KeyBuffer(Clear);
  110.   WriteLn;
  111.   WriteLn;
  112.   WriteLn;
  113. End;
  114.  
  115. Procedure ReadSpeed;
  116.  
  117. Var
  118.   X       :Byte;
  119.   Time    :TimeDate;
  120.   Speed   :Real;
  121.   Sec100  :LongInt;
  122.   Sec100a,
  123.   Sec100b :Word;
  124.   Tot1    :LongInt;
  125.  
  126. Begin
  127.   Total:=0;
  128.   Assign(F,TempFile);
  129.   Repeat
  130.     Reset(F,1);
  131.     GetTime(Time.Hour,Time.Min,Time.Sec,Sec100a);
  132.     GetDate(Time.Year,Time.Month,Time.Day,Time.WeekDay);
  133.     Tot1:=TotalSeconds(Time);      {The Current Time, In Seconds}
  134.     For X:=1 to 10 do
  135.       BlockRead(F,P^,64000);
  136.     GetTime(Time.Hour,Time.Min,Time.Sec,Sec100b);
  137.     GetDate(Time.Year,Time.Month,Time.Day,Time.WeekDay);
  138.     Tot1:=TotalSeconds(Time) - Tot1;     {Current Time Less The Time Above}
  139.     Sec100:=Integer(Sec100b) - Integer(Sec100a);
  140.     Sec100:=Sec100+LongInt(Tot1)*100;    {Time Taken in ms}
  141.     If Sec100=0 Then Sec100:=1;
  142.     Speed:=(640000.0 / (Sec100 / 100.0)) / 1024.0;   {Speed}
  143.     Inc(Total);
  144.     Speeds[Total]:=Speed;
  145.     PushXYPos;
  146.     WriteLn('Last     Read : ',Speed:5:2,' kb per second.  ');
  147.     If Total>1 Then
  148.       WriteLn('Average  Read : ',AvSpeed:5:2,' kb per second.   ',Total:4,' Tests Complete.  ');
  149.     PopXYPos;
  150.   Until KeyPressed Or (Total=1000);
  151.   Close(F);
  152.   KeyBuffer(Clear);
  153.   WriteLn;
  154.   WriteLn;
  155.   WriteLn;
  156. End;
  157.  
  158. Begin
  159.   WriteLn;
  160.   WriteLn('Pure DOS Disk Speed          Version 1.01            Michael Gallias 1992');
  161.   WriteLn;
  162.   WriteLn;
  163.   WriteLn;
  164.   WriteLn;
  165.   GotoXY(1,WhereY-3);
  166.   New(P);
  167.   CreateFile;
  168.   WriteSpeed;
  169.   WriteLn;
  170.   WriteLn;
  171.   WriteLn;
  172.   WriteLn;
  173.   GotoXY(1,WhereY-3);
  174.   ReadSpeed;
  175.   Dispose(P);
  176.   Assign(F,TempFile);
  177.   Erase(F);
  178. End.
  179.  
  180.